package com.clover.templates.web;


import com.clover.templates.dto.Person;
import com.clover.templates.util.BinderUtil;
import lombok.extern.java.Log;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Map;

/**
 * @author FoLafClover
 * @date 2018/5/6/006
 */
@Controller
@RequestMapping("users")
@Log
public class UserController {

    /**
     * 获取用户信息
     * @param map
     * @return
     */
    @RequestMapping(value = "get" ,method = RequestMethod.GET)
    public String getUsers(Map map){
        Binder binder = BinderUtil.getBinder();

        Person person = new Person("Tarry",25);

        List<Person> persons = binder.bind("com.clover.templates.dto.persons", Bindable.listOf(Person.class)).get();

        map.put("person",person);
        map.put("persons",persons);
        map.put("msg","获取用户信息");
        log.info("获取用户信息");
        return "index";
    }
}
